﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Wys.DataForm.CSharp
{
    public partial class MenuIcoManager : Wys.Control.Vb.AutoAdjustFrom
    {
        public MenuIcoManager()
        {
            InitializeComponent();
        }

        private String _IconName = "";
        public String IconName
        {
            get
            {
                return _IconName;
            }
            set
            {
                _IconName = value;
            }
        }

        private void MenuIcoManager_Load(object sender, EventArgs e)
        {
            ImageList il = this.cDllRelease.GetMenuImageList();
            this.lstIcon.SmallImageList = il;
            for (int i = 0; i < il.Images.Count; i++)
            {
                this.lstIcon.Items.Add(lstIcon.SmallImageList.Images.Keys[i], "", i);
            }

        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }

        private void lstIcon_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.lstIcon.SelectedItems.Count == 0)
            {
                return;
            }
            this._IconName = this.lstIcon.SmallImageList.Images.Keys[this.lstIcon.SelectedItems[0].Index];
 
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            if (this.lstIcon.SelectedItems.Count > 0)
            {
                this._IconName = this.lstIcon.SmallImageList.Images.Keys[this.lstIcon.SelectedItems[0].Index];
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void lstIcon_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            btnOk_Click(null, null);
        }
    }
}
